package model

import "sync"

// User 定义了用户结构
type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Role     string `json:"role"`
}

// tokenStore 存放 token 和角色的映射
var TokenStore = struct {
	sync.RWMutex
	Data map[string]string
}{
	Data: make(map[string]string),
}

// ValidUsers 保存所有合法的用户名/密码/角色
var ValidUsers = []User{
	{Username: "test", Password: "pass123", Role: "normal"},
	{Username: "p1", Password: "pass", Role: "normal"},
	{Username: "sj", Password: "readCarefully", Role: "admin"},
	{Username: "p2", Password: "pass1", Role: "admin"},
}

// LoginRequest 前端登录请求
type LoginRequest struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

// LoginResponse 后端统一响应格式
type LoginResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Role    string `json:"role,omitempty"`
	Token   string `json:"token,omitempty"`
}
